package com.bodu.depress.service.impl;

import com.bodu.depress.entity.request.DepressCollectResultRequest;
import com.bodu.depress.entity.vo.DepressCollectResultVo;
import com.bodu.depress.mapper.DepressCollectResultMapper;
import com.bodu.core.entity.ParamReq;
import com.bodu.depress.service.DepressCollectResultService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * 题集解析 Service impl
 *
 * @author Administrator
 */
@Service
public class DepressCollectResultServiceImpl implements DepressCollectResultService {

    @Resource
    private DepressCollectResultMapper depressCollectResultMapper;

    @Override
    public DepressCollectResultVo getModel(Long id) {
        return depressCollectResultMapper.getModel(id);
    }

    @Transactional
    @Override
    public Long save(DepressCollectResultRequest request) {
        depressCollectResultMapper.save(request);
        return request.getId();
    }

    @Transactional
    @Override
    public Long update(DepressCollectResultRequest request) {
        depressCollectResultMapper.update(request);
        return request.getId();
    }

    @Override
    public List<DepressCollectResultVo> listPage(ParamReq<DepressCollectResultRequest> params) {
        params.setStartIndex((params.getCurrent() - 1) * params.getSize());
        return depressCollectResultMapper.listPage(params);
    }

    @Override
    public Integer countPage(ParamReq<DepressCollectResultRequest> params) {
        return depressCollectResultMapper.countPage(params);
    }

    @Override
    public Integer updateDelFlagById(Long id, Integer delFlag) {
        return depressCollectResultMapper.updateDelFlagById(id, delFlag);
    }

    @Override
    public DepressCollectResultVo findDepressResultByCollectIdAndScore(Long collectId, Integer score) {
        return depressCollectResultMapper.findDepressResultByCollectIdAndScore(collectId, score);
    }
}
